#include<stdio.h>
int main ()
{
	int n;
	int m;
	int Index_K;
	while(scanf("%d",&n)!=EOF&&n<=20&&m<=20&&Index_K<=20)
	{
	int a[n+1];
	int i,j;
	
	for (i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	scanf("%d",&a[n]);
	scanf("%d",&Index_K);
	int MAX;
	int tidai;
	for (i=0;i<n+1;i++)
	{
		
		MAX=a[i];
		for(j=i+1;j<n+1;j++)
		{
			
			if(MAX>a[j])
			{
				tidai=a[j];
				a[j]=a[i];
				a[i]=tidai;
				MAX=a[i];
			}
		}
		a[i]=MAX;
	}
	for (i=0;i<n+1;i++)
	{
		printf("%d\40",a[i]);
		
	}
	printf("\n");
	printf("%d\n",a[Index_K]);
	}
	return 0;
} 
